﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ZLDC.Common.Estate;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace ZLDC.Topo.BLL.Estate
{
    public class lp_Report_list
    {
                                        public static string GetType(string deptid)
        {
            string sql = "select type from t_zlhq_t_s_alldept where DltFlg=0 and id=" + deptid;
            DataSet ds = ZLDC.Topo.BLL.Estate.lp_Basis.Getds(sql);
            if (ZLDC.Topo.BLL.Estate.lp_Basis.rtcount(ds))
            {
                return ds.Tables[0].Rows[0][0].ToString();
            }
            return "";
        }
        
                                                public static string GetTableCount(string deptid)
        {
            string sql = "select top 1 * from v_lp_mainlist where (id=" + deptid + " or expr1=" + deptid + " or expr3=" + deptid + " or expr5=" + deptid + " )";
            DataSet ds = ZLDC.Topo.BLL.Estate.lp_Basis.Getds(sql);
            string tbdeptid = _Utility.GetInfoBySession().m_sDeptID;
            if (ds.Tables.Count > 0)
            {
                if (ds.Tables[0].Select(" id=" + tbdeptid + " or expr1=" + tbdeptid + " or expr3=" + tbdeptid + " or expr5=" + tbdeptid + "").Length > 0)
                {
                    return "1";
                }
                else
                {
                    return "0";
                }
            }
            else
            {
                return "0";
            }
        }

                                                         public static string GetSql(string sqlwhere, string statrday, string endday)
        {
            string sql = "select BasisName,sum(Actual_Goal) as Actual_Goal ,sum(Actual_Number) as Actual_Number   from lp_Configuration   " + sqlwhere + " and CONVERT(varchar,CreateTime,23) >=" + statrday + " and CONVERT(varchar,CreateTime,23)<=" + endday + " and (Actual_Goal>0 or Actual_Number>0)  group by  BasisName ";
            return sql;
        }
                                                                                                
                                                                public static string GetSql_1(string sqlwhere, string statrday, string endday)
        {
            string sql = "select  BasisName,sum(Actual_Goal) as Actual_Goal,sum(Actual_Number) as Actual_Number   from lp_Configuration    " + sqlwhere + "  and CONVERT(varchar,CreateTime,23) >=" + statrday + " and CONVERT(varchar,CreateTime,23)<=" + endday + " and (Actual_Goal>0 or Actual_Number>0)   group by  BasisName";
            return sql;
        }
    }
}
